import requests
from flask import current_app as app


class KunLun:
    headers = {
        'Content-Type': 'application/json',
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51"
    }

    def __init__(self) -> None:
        self.server = app.config['KUNLUN']['server']

    def active_follows(self, payload=None, check_repeat=''):
        uri = f'/kunlun/market/api/v1/public/active-follows?checkRepeat={check_repeat}'
        app.logger.info(f'request: {uri}')
        app.logger.info(f'payload: {payload}')
        response = requests.request(
            "POST",
            url=f'{self.server}/kunlun/market/api/v1/public/active-follows?checkRepeat={check_repeat}',
            headers=self.headers, json=payload)
        app.logger.info(f'response: {response.text}')
